home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / OS / FWGraphx / Include / FWPat.h < prev    next >
Encoding:
Text File  |  1994-04-21  |  3.3 KB  |  111 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWPat.h
  4. //    Release Version:    $ 1.0d1 $
  5. //
  6. //    Creation Date:        3/28/94
  7. //
  8. //    Copyright:    © 1993, 1994 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #ifndef FWPAT_H
  13. #define FWPAT_H
  14.  
  15. #ifndef FWPRIMEM_H
  16. #include "FWPriMem.h"
  17. #endif
  18.  
  19. #ifndef FWSTREAM_H
  20. #include "FWStream.h"
  21. #endif
  22.  
  23. // ----- Quickdraw Includes -----
  24.  
  25. #if defined(FW_BUILD_MAC) && !defined(__QUICKDRAW__)
  26. #include <QuickDraw.h>
  27. #endif
  28.  
  29. //==============================================================================
  30. //    •• Standard Patterns (should be moved somewhere else)
  31. //==============================================================================
  32.  
  33. const char FW_kBlackPat[8]         = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
  34. const char FW_kWhitePat[8]            = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  35.  
  36. const char FW_kGrayPat[8]             = {0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA};
  37. const char FW_kLightGrayPat[8]     = {0xEE, 0x44, 0xEE, 0x44, 0xEE, 0x44, 0xEE, 0x44};
  38. const char FW_kDarkGrayPat[8]         = {0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD};
  39.  
  40. const char FW_kHorizontalPat[8]     = {0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00};
  41. const char FW_kVerticalPat[8]         = {0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11};
  42. const char FW_kFDiagonalPat[8]     = {0x88, 0x44, 0x22, 0x11, 0x88, 0x44, 0x22, 0x11};
  43. const char FW_kBDiagonalPat[8]     = {0x11, 0x22, 0x44, 0x88, 0x11, 0x22, 0x44, 0x88};
  44. const char FW_kCrossPat[8]         = {0x88, 0x88, 0x88, 0xFF, 0x88, 0x88, 0x88, 0xFF};
  45. const char FW_kDiagCrossPat[8]     = {0x88, 0x55, 0x22, 0x55, 0x88, 0x55, 0x22, 0x55};
  46.  
  47. const char FW_kAntPat[8]             = {0xCC, 0x66, 0x33, 0x99, 0xCC, 0x66, 0x33, 0x99};
  48.  
  49. //==============================================================================
  50. //    •• CLASS FW_CPattern
  51. //==============================================================================
  52.  
  53. class FW_CPattern
  54. {
  55. //------------------------------------------------------------------------------
  56. //    • Constructors/Destructors
  57. //
  58. public:
  59.     FW_CPattern();
  60.     FW_CPattern(const char* pattern);
  61.     FW_CPattern(const FW_CPattern& otherPattern);
  62.         
  63. //------------------------------------------------------------------------------
  64. //    • New API
  65. //
  66. public:
  67. #ifdef FW_BUILD_MAC
  68.     operator const Pattern*() const
  69.         {return (Pattern*)&fPattern;}
  70.     operator const Pattern&() const
  71.         {return *((Pattern*)&fPattern);}
  72. #endif
  73.     
  74.     operator const char*() const
  75.         {return fPattern;}
  76.  
  77.     FW_CPattern& operator=(const FW_CPattern& otherPattern);
  78.     FW_CPattern& operator=(const char* otherPattern);
  79.     
  80.     char&         operator[](short index)
  81.                     {return fPattern[index];}
  82.     char         operator[](short index) const
  83.                     {return fPattern[index];}
  84.  
  85.     void         Invert();
  86.     
  87.     void        FlipHorizontaly();
  88.     void        FlipVerticaly();
  89.     
  90.     void        ShiftUp();
  91.     void        ShiftDown();
  92.     void        ShiftLeft();
  93.     void        ShiftRight();
  94.  
  95.     void        Flatten(FW_CWritableStream& stream)
  96.                     {stream.Write(fPattern, 8);}
  97.     void        Unflatten(FW_CReadableStream& stream)
  98.                     {stream.Read(fPattern, 8);}
  99.     
  100. private:
  101.     void        MovePattern(const char* source, char* destination)
  102.                     {FW_PrimitiveCopyMemory(source, destination, 8);}
  103.     
  104. //------------------------------------------------------------------------------
  105. //    • Data Member
  106. //
  107. private:    
  108.     char        fPattern[8];        // OPF convention 1:foreground     0:background
  109. };
  110.  
  111. #endif